/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package me.zhengjie.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://eladmin.vip
* @description /
* @author wuhj
* @date 2023-09-16
**/
@Entity
@Data
@Table(name="exams_answers")
public class Answers implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "`id`")
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(name = "`user_id`")
    @ApiModelProperty(value = "试卷人")
    private String userId;

    @Column(name = "`subject_id`")
    @ApiModelProperty(value = "科目")
    private Long subjectId;

    @Column(name = "`content`")
    @ApiModelProperty(value = "提交答案")
    private String content;

    @Column(name = "`score`")
    @ApiModelProperty(value = "系统判分")
    private Integer score;

    @Column(name = "`final_score`")
    @ApiModelProperty(value = "最终判分")
    private Integer finalScore;

    @Column(name = "`start_ts`")
    @ApiModelProperty(value = "开始时间")
    private Timestamp startTs;

    @Column(name = "`desc`")
    @ApiModelProperty(value = "备注")
    private String desc;

    @Column(name = "`commit_ts`")
    @CreationTimestamp
    @ApiModelProperty(value = "提交时间")
    private Timestamp commitTs;

    @Column(name = "`commitor`")
    @ApiModelProperty(value = "提交人")
    private String commitor;

    @Column(name = "`updator`")
    @ApiModelProperty(value = "更新人")
    private String updator;

    @Column(name = "`update_ts`")
    @UpdateTimestamp
    @ApiModelProperty(value = "更新时间")
    private Timestamp updateTs;

    public void copy(Answers source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
